package br.com.colegio.dao.storage;

import java.util.Collection;
import java.util.HashMap;
import java.util.Map;

import br.com.colegio.dao.CodigoRetornoDAO;
import br.com.colegio.vo.CodigoRetorno;

public class CodigoRetornoData
{
	private static CodigoRetornoData instance;
	private Map<Integer, CodigoRetorno> data = new HashMap<Integer, CodigoRetorno>(); 

	private CodigoRetornoData()
	{
	}

	public static CodigoRetornoData getInstance()
	{
		if (instance == null)
			instance = new CodigoRetornoData();

		return instance;
	}

	public CodigoRetorno getCodigoRetorno(int cod)
	{
		if (data.size() == 0)
		{
			Collection<Object> r = CodigoRetornoDAO.list();

			if (r != null)
				for (Object o : r)
				{
					CodigoRetorno c = (CodigoRetorno)o;
					data.put(c.getCodigo(), c);
				}
		}

		return data.get(cod);
	}
}